/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("tb_project_baseinfo",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using MYData.Entity.DomainModels;
using MYData.System.IServices;
using Microsoft.AspNetCore.Authorization;
using System.Collections.Generic;
using System.Net;
using MYData.Core.Utilities;
using MYData.Entity.DTO.ApiEntity.Input;

namespace MYData.System.Controllers
{
    public partial class tb_project_baseinfoController
    {
        private readonly Itb_project_baseinfoService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;

        [ActivatorUtilitiesConstructor]
        public tb_project_baseinfoController(
            Itb_project_baseinfoService service,
            IHttpContextAccessor httpContextAccessor
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }
        /// <summary>
        /// 项目立项基本信息表添加
        /// </summary>
        /// <param name="inputdto"></param>
        /// <returns></returns>
        [HttpPost, Route("BaseInfoAdd")] 
        public async Task<IActionResult> BaseInfoAdd([FromBody]baseinfoInputDto inputdto)
        {
            return Json(await _service.BaseInfoAdd(inputdto));
        }
        /// <summary>
        /// 项目立项基本信息表修改
        /// </summary>
        /// <param name="updatedto"></param>
        /// <returns></returns>
        [HttpPost, Route("BaseInfoUpt")]
        public async Task<IActionResult> BaseInfoUpt([FromBody] baseinfoUpdateDto updatedto)
        {
            return Json(await _service.BaseInfoUpt(updatedto));
        }
        /// <summary>
        /// 项目立项基本信息表暂存（添加）
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [HttpPost, Route("ProductInfoAddTsAsync")]
        [AllowAnonymous]
        public IActionResult ProductInfoAddTsAsync([FromBody] ProjectInfoTsInput_Dto inputDto)
        {
            return Json(_service.ProductInfoAddTsAsync(inputDto));
        }
        /// <summary>
        /// 项目立项基本信息表暂存（修改）
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [HttpPost, Route("ProductInfoUptTsAsync")]
        [AllowAnonymous]
        public IActionResult ProductInfoUptTsAsync([FromBody] ProjectInfoTsUpt_Dto UpdateDto)
        {
            return Json(_service.ProductInfoUptTsAsync(UpdateDto));
        }
        /// <summary>
        /// 项目立项基本信息根据主键查找
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns></returns>
        [HttpGet, Route("BaseinfoSearch"),AllowAnonymous]
        public async Task<IActionResult> BaseinfoSearch(string projectId)
        {
            return Json(await _service.BaseinfoSearch(projectId));
        }
        /// <summary>
        /// 立项信息根据主键查询
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns></returns>
        [HttpGet,Route("ProjectApprovalInformation")]
        public async Task<IActionResult> ProjectApprovalInformation(string projectId)
        {
            return Json(await _service.ProjectApprovalInformation(projectId));
        }
        /// <summary>
        /// 获取项目立项信息列表
        /// </summary>
        /// <returns></returns>
        [HttpGet, Route("GetProjectListAsync")]
        public async Task<IActionResult> GetProjectListAsync(string? projectName="", int size=10, int index=1)
        {
            return Json(await _service.GetProjectListAsync(projectName,size,index));
        }
        /// <summary>
        /// 项目名称唯一判断
        /// </summary>
        /// <param name="projectName"></param>
        /// <returns></returns>
        [HttpGet, Route("ProjectNameSole")]
        public async Task<IActionResult> ProjectNameSole(string projectName)
        {
            return Json(await _service.ProjectNameSole(projectName));
        }
        /// <summary>
        /// 项目编号唯一判断
        /// </summary>
        /// <param name="projectName"></param>
        /// <returns></returns>
        [HttpGet, Route("ProjectNumSole")]
        public async Task<IActionResult> ProjectNumSole(string projectNum)
        {
            return Json(await _service.ProjectNumSole(projectNum));
        }
        /// <summary>
        /// 根据主键删除立项基本信息
        /// </summary>
        /// <param name="projectid"></param>
        /// <returns></returns>
        [HttpPost, Route("DelProject")]
        public async Task<IActionResult> DelProject(string projectid)
        {
            return Json(await _service.DelProject(projectid));
        }


    }
}
